<?php

/**
 * Description of Helpers_SiteMap
 *
 * @author a.novikov
 */
class Helpers_SiteMap extends Helpers_Base {

	public function getViewPath($level = 0) {
		return 'site_map.tpl';
	}

	public function siteMap($id = 0, $level = 0) {
		$id = (int)$id;
		$level = (int)$level;

		if ($level > 2) {
			return '';
		}

		$this->view->next_level = $level + 1;
		
//		if (!$id) {
//			$peer = ProductCategoryPeer::getInstance();
//			$fullRowset = $peer->fetchAll();
//			$peer->setCacheRowset($fullRowset);
//		}

		$rowset = Categories::getInstance()->getChildRowset($id);
		$this->view->categories = ContentList::factoryByClassName('List_ProductCategory_SiteMap', $rowset);

		return $this->render();
	}
}